package src.servletDao;

import java.util.List;

import org.apache.commons.dbutils.handlers.BeanListHandler;
import src.servletDb.DBDriverFactory;
import src.servletbean.UsersBean;

public class LoginDao {
       
	public boolean isLogined(UsersBean usersB){
		boolean isL=false;
		//登录验证sql语句
		String strSql="SELECT * FROM EDUUSERS WHERE USERNAME=? AND USERPSW=?";
		List<UsersBean> lst=DBDriverFactory.getDBDriverInstance().query(strSql, 
				new BeanListHandler<UsersBean>(UsersBean.class),
				new Object[]{usersB.getUsername(),usersB.getUserpsw()});
		// 根据查询结果判定用户是否登录成功
				if (lst!= null && lst.size() > 0) {
					// 登录验证成功
					isL = true;
				}
		return isL;
	}
	
	/**
	 * 用户登录验证
	 * 
	 * @param usersB
	 *            用户信息实体对象
	 * @return 登录验证结果信息
	 */
	public List<UsersBean> isLogined2(UsersBean usersB) {
		// 登录验证sql语句
		String strSql = "SELECT * FROM EDUUSERS WHERE USERNAME = ? AND USERPSW = ?";
		List<UsersBean> lstUsers = DBDriverFactory.getDBDriverInstance().query(strSql,
				new BeanListHandler<UsersBean>(UsersBean.class),
				new Object[] { usersB.getUsername(), usersB.getUserpsw() });

		return lstUsers;
	}
}
